<?php

namespace app\admin\validate\user;

use think\Validate;

class Identity extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'name' => 'require|max:50',
        'direct_reward' => 'require|float|egt:0',
        'direct_reward_count' => 'require|integer|egt:0',
        'indirect_reward' => 'require|float|egt:0',
        'indirect_reward_count' => 'require|float|egt:0',
        'purchase_amount' => 'require|integer|egt:0',
        'icon' => 'require',
        'status' => 'require|in:0,1',
    ];
    
    /**
     * 提示消息
     */
    protected $message = [
        'name.require' => '身份名称不能为空',
        'name.max' => '身份名称不能超过50个字符',
        'direct_reward.require' => '直推奖励不能为空',
        'direct_reward.float' => '直推奖励必须是浮点数',
        'direct_reward.egt' => '直推奖励必须大于等于0',
        'direct_reward_count.require' => '链下收益人数不能为空',
        'direct_reward_count.integer' => '链下收益人数必须是整数',
        'direct_reward_count.egt' => '链下收益人数必须大于等于0',
        'indirect_reward.require' => '链下权益积分收益不能为空',
        'indirect_reward.float' => '链下权益积分收益必须是浮点数',
        'indirect_reward.egt' => '链下权益积分收益必须大于等于0',
        'indirect_reward_count.require' => '链下绿色积分收益不能为空',
        'indirect_reward_count.float' => '链下绿色积分收益必须是浮点数',
        'indirect_reward_count.egt' => '链下绿色积分收益必须大于等于0',
        'purchase_amount.require' => '购买金额不能为空',
        'purchase_amount.integer' => '购买金额必须是整数',
        'purchase_amount.egt' => '购买金额必须大于等于0',
        'icon.require' => '身份图标不能为空',
        'status.require' => '状态不能为空',
        'status.in' => '状态必须是0,1',
    ];
    
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['name', 'direct_reward', 'direct_reward_count', 'indirect_reward', 'indirect_reward_count', 'purchase_amount', 'icon', 'status'],
        'edit' => ['name', 'direct_reward', 'direct_reward_count', 'indirect_reward', 'indirect_reward_count', 'purchase_amount', 'icon', 'status'],
    ];
}